package com.lhm;

public class test2 {
    String name;
    int age;

    public test2(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public  void eat() {
        System.out.println(name+"吃饭");
    }
}

class Cat extends test2 {
    public Cat(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"吃鱼");
    }
}

class dog extends test2{

    public dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+"吃骨头");
    }
}

 class t{
    //方法传参
    public static void  eat(test2 testx){
        testx.eat();
    }

     public static void main(String[] args) {
        //直接赋值
        test2 cat = new Cat("元宝", 2);
         test2 dog = new dog("小七", 1);

         eat(cat);
         eat(dog);
     }
}


